#我们创建一个多级菜单
from tkinter import *
root = Tk()
def callback1():
    print("打开")

def callback2():
    print("关闭")

def callback3():
    print("退出")

def callback4():
    print("剪贴")

def callback5():
    print("拷贝")

def callback6():
    print("粘贴")

menubar = Menu(root)  #创建一个顶级菜单
filemenu = Menu(menubar,tearoff = False) #创建一个顶级菜单下的子菜单
menubar.add_cascade(label = "文件",menu = filemenu)  #为子菜单起个名字
filemenu.add_command(label = "打开",command = callback1)
filemenu.add_command(label = "关闭",command = callback2)
filemenu.add_separator()  #增加分隔符
filemenu.add_command(label = "退出",command = callback3)

editmenu = Menu(menubar,tearoff = False)
menubar.add_cascade(label = "编辑",menu = editmenu)
editmenu.add_command(label = "剪贴",command = callback4)
editmenu.add_command(label = "拷贝",command = callback5)
editmenu.add_command(label = "粘贴",command = callback6)

#显示菜单
root.config(menu = menubar)
mainloop()
